extends VBoxContainer
@onready var demo_card: Panel = $DemoCard

func _ready() -> void:
	demo_card.hide()
	await owner.ready
	_init_ball_card()

func _init_ball_card() -> void :
	for ball in GlobalData.save_ball :
		var card = demo_card.duplicate()
		var new_button : Button = card.get_child(0)
		new_button.text = ball.data_item.ball_name
		new_button.disabled = ball.data_item.is_lock
		new_button.button_up.connect(_call_back.bind(new_button,ball))
		card.show()
		call_deferred("add_child",card)

func _call_back(button : Button, ball : CharacterBody2D) -> void :
	if not button.is_hovered() : return
	if ball.data_item.is_lock : return
	GlobalData.current_ball = ball
	get_tree().change_scene_to_file("uid://dfnu1ugnfo32i")
